import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Scythe here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Scythe extends Trap
{
    private int dir;
    private int step=0;
    private final int RIGHT=0;
    private final int LEFT=1;
    private Timer rotationTimer=new Timer();
    
    public Scythe(int x,int del,int iniD)
    {
        super(x,del,iniD);
        
        damage=50;
        
        setImage(new GreenfootImage("scythe1.png"));
    }
    
    public void act() 
    {
        timer.tick();
        activeTimer.tick();
        rotationTimer.tick();
        
        GameWorld world=(GameWorld)getWorld();
        
        setLocation(world.getScrollx()+360+posX,-70);
        
        if(active==true || !activeTimer.wait(initialDelay))     
        activeImage();
        if(active==false)
        return;
        
        if(!rotationTimer.wait(25))
        {
            if(dir==RIGHT)
            {
                if(getRotation()!=270)
                turn(-5);
                else
                if(!timer.wait(delay))
                dir=LEFT;
            }else
            {
                if(getRotation()!=90)
                turn(5);
                else
                if(!timer.wait(delay))
                dir=RIGHT;
            }
        }
        
        if(isTouchingPlayer())
        getPlayer().getHurt(damage);
                       
    }    
}
